
<!DOCTYPE html>
<html lang="en" xmlns:th="http://thymeleaf.org">
<head>
    <th:block th:include="include :: header('定时任务')"/>
</head>
<body class="white-bg">
<div class="container-div">
    <div class="ibox-content">
        <form class="form-horizontal m" id="jobForm" autocomplete="off">
            <input type="hidden" id="jobId" name="jobId" th:value="${jobId}">
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">任务名称：</label>
                <div class="col-sm-8">
                    <input class="form-control" type="text" name="jobName" id="jobName" required>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">任务分组：</label>
                <div class="col-sm-8">
                    <select name="jobGroup" class="form-control m-b">
                        <option th:each="dic,dicStat:${jobGroups}" th:value="${dic.value}">[[${dic.name}]]</option>
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">调用目标字符串：</label>
                <div class="col-sm-8">
                    <input class="form-control" type="text" name="invokeTarget" id="invokeTarget" required>
                    <span class="help-block m-b-none"><i class="fa fa-info-circle"></i> Bean调用示例：ryTask.ryParams('ry')</span>
                    <span class="help-block m-b-none"><i class="fa fa-info-circle"></i> Class类调用示例：com.ruoyi.quartz.task.RyTask.ryParams('ry')</span>
                    <span class="help-block m-b-none"><i class="fa fa-info-circle"></i> 参数说明：支持字符串，布尔类型，长整型，浮点型，整型</span>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">cron表达式：</label>
                <div class="col-sm-8">
                    <input class="form-control" type="text" name="cronExpression" id="cronExpression" required>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">执行策略：</label>
                <div class="col-sm-8">
                    <label class="radio-box"> <input type="radio" name="misfirePolicy" value="1" th:checked="true"/> 立即执行 </label>
                    <label class="radio-box"> <input type="radio" name="misfirePolicy" value="2" /> 执行一次 </label>
                    <label class="radio-box"> <input type="radio" name="misfirePolicy" value="3" /> 不触发执行 </label>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">并发执行：</label>
                <div class="col-sm-8">
                    <label class="radio-box"> <input type="radio" name="concurrent" value="1"/> 允许 </label>
                    <label class="radio-box"> <input type="radio" name="concurrent" value="0" th:checked="true"/> 禁止 </label>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">状态：</label>
                <div class="col-sm-8">
                    <label class="radio-box"> <input type="radio" id="jobStatus" name="jobStatus" value="0"/> 停止 </label>
                    <label class="radio-box"> <input type="radio" id="jobStatus1" name="jobStatus" value="1" th:checked="true"/>正常 </label>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">备注：</label>
                <div class="col-sm-8">
                    <textarea id="remark" name="remark" class="form-control"></textarea>
                </div>
            </div>
            <div class="footerbar">
                <div class="col-sm-12 col-sm-offset-3">
                    <button class="btn btn-primary" type="submit">
                        <i class="fa fa-check"></i>
                        保存
                    </button>
                    <button class="btn btn-danger" type="button" onclick="cancel()">
                        <i class="fa fa-reply-all"></i>关闭
                    </button>
                </div>
            </div>
        </form>

    </div>
</div>

<th:block th:include="include :: footer"/>
<!-- jquery-validate 表单树插件 -->
<script type="text/javascript" th:inline="javascript">
    $(function () {
        $('#jobForm').validator({
            stopOnError: false,
            timely: 2,
            theme: "yellow_right",
            valid: function (form) {
                //console.log(form);
                jutils.ajaxPost("/monitor/job/save",$(form).serialize(),function (res){
                    if(res.status){
                        cancel();
                    }
                });
            },
        });
        loadModel();
    });
    function loadModel(){
        let id=$('#jobId').val();
        if(jutils.emptyId(id)){
            return;
        }
        jutils.ajaxGet('/monitor/job/getmodel',{id:id},function(res){
            // console.log(res);
            if(res.status){
                let model=res.data.model;
                $('#jobForm').initFormData(model);
            }
        });
    }


    function cancel(){
        jutils.closeDialog();
    }

</script>
</body>
</html>